package com.syedu.day17;

import com.google.common.collect.Lists;
import com.syedu.day13.Car;

import java.util.List;

/**
 * description：
 * @author Administrator
 * @date 2022/4/8 16:04
 */
public class StreamAPI3 {
    public static void main(String[] args) {
        Car car1 = new Car("Benz", "E300L", 400000.0);
        Car car2 = new Car("Bmw", "320Li", 250000.0);
        Car car3 = new Car("Audi", "Q7", 700000.0);
        Car car4 = new Car("Byd", "汉EV", 250000.0);
        Car car11 = new Car("Byd", "汉EV", 250000.0);
        Car car5 = new Car("Benz", "C200L", 250000.0);
        Car car6 = new Car("Audi", "A4L", 300000.0);
        Car car7 = new Car("Bmw", "M3", 800000.0);
        Car car8 = new Car("Benz", "EQS", 1500000.0);
        Car car9 = new Car("Audi", "e-tron", 700000.0);
        Car car10 = new Car("Audi", "R8", 2300000.0);
        List<Car> carList = Lists.newArrayList(car1, car2, car3, car4, car11, car5, car6, car7, car8, car9, car10);

        //distinct()排重,skip+limit相当于分页,sorted表示排序
        carList.stream().distinct().skip(3).limit(5).sorted((o1, o2) -> o2.getPrice().compareTo(o1.getPrice())).forEach(System.out::println);
    }

    /**
     * 把List集合转换成map集合
     */
    /*public static Map<String,List<Car>> categoryCars(List<Car> cars){

    }*/
}